import Footer from "@/components/common/footer";
import { mapGetters, mapActions } from "vuex";
import template from "./AppTemplate";
const { render, staticRenderFns } = template;

export default {
  render,
  staticRenderFns,
  components: {
    Footer,
  },
  name: "App",
  data() {
    return {
      platformName: "",
    };
  },
  mounted() {},
  created() {},
  computed: {
    ...mapGetters(["platformConfig", "navShow", "token"]),
  },
  methods: {
    ...mapActions([
      "SET_USER_INFO_DATA",
      "SET_ACCOUNT_DATA",
      "SET_PLATFORM_CONFIG",
      "SET_CASINO_SWITCH",
    ]),
    setFaviconIcon() {
      if (this.platformConfig.android_line) {
        let link =
          document.querySelector("link[rel*='icon']") ||
          document.createElement("link");
        link.type = "image/x-icon";
        link.rel = "shortcut icon";
        link.href = this.platformConfig.favicon_ico;
        document.getElementsByTagName("head")[0].appendChild(link);
      }
    },
  },
  watch: {
    platformConfig(obj) {
      if (obj.platform_name) {
        this.platformName = this.platformConfig.platform_name;
        document.title = this.platformName;
      }
      if (obj.favicon_ico) {
        this.setFaviconIcon();
      }
    },
    $route(to, from) {
      if (from.path == "/") {
        if (to.query.token) {
          //第三方跳过来
          localStorage.setItem("token", to.query.token);
        }
        if (to.query.isUser) {
          localStorage.setItem("isUser", to.query.isUser);
        }
        if (localStorage.getItem("token")) {
          this.SET_USER_INFO_DATA({
            Obj: {},
          });
          this.SET_ACCOUNT_DATA({
            Obj: {},
          });
        }
        this.SET_PLATFORM_CONFIG({
          Obj: {},
        });
        this.SET_CASINO_SWITCH({
          Obj: {},
        });
      }

      // if( to.path=='/login'
      //       || to.path=='/reg'
      //       || to.path.indexOf('/redPacket')!= -1
      //       || to.path.indexOf('/room')!= -1
      //       || to.path.indexOf('/personal/')!= -1
      //       || to.path.indexOf('/recharge')!= -1
      //       || to.path.indexOf('/bank')!= -1
      //       || to.path=='/agencyShare'
      //       || to.path=='/agencyRole'
      //       || to.path=='/personal'
      //       || to.path=='/bettingRecord'
      //       || to.path=='/teamManagement'
      //       || to.path=='/member'
      //       || to.path=='/theTeamReports'
      //       || to.path=='/statistics'
      //       || to.path=='/insertingCoil'
      //       || to.path=='/setting'
      //       || to.path=='/revisePsd'
      //       || to.path=='/record'
      //       || to.path=='/avaterPage'
      //       || to.path=='/teamReportDetail'
      //       || to.path=='/memberDetail'
      //       || to.path=='/paySet'
      //       || to.path=='/paysafe'
      //       || to.path=='/moneyPassword'
      //       || to.path=='/withdraw'
      //       || to.path=='/whdProgress'
      //       || to.path=='/msgCenter'
      //       || to.path=='/lotteryResult'
      //       || to.path=='/lotteryTrend'
      //       || to.path=='/dataDetail'
      //       || to.path=='/touZhuDetail'
      //       || to.path=='/recordDetail'
      //       || to.path=='/DealRecord'
      //       || to.path=='/activityCenter'
      //       || to.path=='/sudoku'
      //       || to.path=='/aboutUs'
      //       || to.path=='/contact'
      //       || to.path=='/feedback'
      //       || to.path=='/faqDetails'
      //     ){
      if (
        to.path != "/" &&
        to.path != "/home" &&
        to.path != "/wallet" &&
        to.path != "/moneyTransform" &&
        to.path != "/activityCenter" &&
        to.path != "/personalCenter"
      ) {
        this.$store.dispatch("NAV_HIDE");
        this.$refs.app.style = "";
      } else {
        this.$store.dispatch("NAV_SHOW");
        this.$refs.app.style = "padding-bottom: 1.333333rem /* 100/75 */;";
        // if (to.path=='/home') {
        //   if (!localStorage.getItem("token")) {
        //     this.SET_ACCOUNT_DATA({
        //       obj: {}
        //     });
        //     this.SET_ACCOUNT_DATA({
        //       Obj: {}
        //     });
        //   }
        // }
      }
    },
  },
};

// WEBPACK FOOTER //
// ./src/App.vue
